package pres.dnf.test.java.springcloud.client.hystrix.ribbon.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.client.RestTemplate;

/**
 * @author dengfan
 * @version 1.0
 * @description
 * @date 2018/9/11 0011 16:41
 */
@Service
public class OpsConsumerService {
    @Autowired
    private RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "addServiceFallback")
    public String add(){
        return restTemplate.getForEntity("http://OPS-SERVICE-DNF/add?a=12&b=21",String.class).getBody();
    }

    public String addServiceFallback() {
        return "error";
    }
}
